package cn.kgc.controller;

import cn.kgc.grace.result.GraceJSONResult;
import cn.kgc.interceptor.JwtInterceptor;
import cn.kgc.service.SysParamsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author YC
 */
@RestController
@RequestMapping("/sysParams")
@Api(tags = "系统参数相关接口")
@Slf4j
public class SysParamsController {

    @Resource
    private SysParamsService sysParamsService;

    @PostMapping("/admin/getRefreshMaxCount")
    @ApiOperation(value = "获取刷新最大次数")
//    @RequireLogin(value = LoginType.USER_ADMIN_LOGIN)
    public GraceJSONResult getRefreshMaxCount() {
        sysParamsService.getRefreshMaxCount();
        return GraceJSONResult.ok();
    }

    @PostMapping("/admin/modifyRefreshMaxCount")
    @ApiOperation(value = "修改刷新最大次数")
//    @RequireLogin(value = LoginType.USER_ADMIN_LOGIN)
    public GraceJSONResult modifyRefreshMaxCount(int maxCount) {
        sysParamsService.modifySysParams(maxCount);
        return GraceJSONResult.ok();
    }

    @PostMapping("/refreshResume")
    @ApiOperation(value = "刷新简历")
//    @RequireLogin(value = LoginType.USER_APP_LOGIN)
    public GraceJSONResult refreshResume(String resumeId, String loginUserId) {
        String userId = JwtInterceptor.userIds.get();
        return GraceJSONResult.ok(sysParamsService.refreshResume(resumeId, loginUserId));
    }

}
